package com.redteam.data.dao.interfaces;

import java.sql.*;
import java.util.List;
import javax.sql.DataSource;

/**
 * Contains DAO interface methods
 * @author Stephen Lawton
 * @author Jezreel Wilson
 */
public interface DAO {

    /**
     * Gets single <code>Object</code> out of database by passing that <code>Object</code>
     * @param obj
     * <code>Object</code> to find
     * @return
     * <code>Object</code> that is searched for.
     * @throws SQLException
     */
    Object getSingle(Object obj) throws SQLException;
    /**
     * Gets single <code>Object</code> out of database by <code>ID</code> and <code>Discriminator</code>
     * @param id
     * Id of <code>Object</code> specified
     * @param descriminator
     * Type of <code>Object</code> searched for.
     * @return
     * <code>Object</code> that is searched for
     * @throws SQLException
     */
    Object getSingle(long id, String descriminator) throws SQLException;

    /**
     * Gets single <code>Object</code> out of database by <code>ID</code>
     * @param primaryKey
     * Id of <code>Object</code> specified
     * @return
     * <code>Object</code> that is searched for
     * @throws SQLException
     */
    Object getSingle(long primaryKey) throws SQLException;

    /**
     * Removes <code>Object</code> from database by passing that <code>Object</code>
     * @param obj
     * <code>Object</code> to remove
     * @return
     * @throws SQLException
     */
    int remove(Object obj) throws SQLException;

    /**
     *
     * @param primaryKey
     * @return
     * @throws SQLException
     */
    int remove(long primaryKey) throws SQLException;

    /**
     *
     * @param objs
     * @return
     * @throws SQLException
     */
    int removeMany(List<Object> objs) throws SQLException;

    /**
     *
     * @param obj
     * @return
     * @throws SQLException
     */
    int insert(Object obj) throws SQLException;

    /**
     *
     * @param objs
     * @return
     * @throws SQLException
     */
    int insertMany(List<Object> objs) throws SQLException;

    /**
     *
     * @param obj
     * @return
     * @throws SQLException
     */
    int update(Object obj) throws SQLException;

    /**
     *
     * @return
     * @throws SQLException
     */
    List<Object> getAll() throws SQLException;

    /**
     * 
     * @param discriminator
     * @return
     * @throws SQLException
     */
    List<Object> getAll(String discriminator) throws SQLException;

    /**
     * Sets the table to specified table.
     *
     * @return
     */
    String getTableName();

    /**
     *
     * @return
     */
    DataSource getDS();
}
